package com.example.securitydemo.controller;

import com.example.securitydemo.mapper.UserMapper;
import com.example.securitydemo.model.po.User;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GetMapping(value = "/hello")
    public String hello(){
        return "say hello";
    }

    @GetMapping(value = "/hasAuth1")
    public String hasAuth1(){
        return "/hasAuth1";
    }

    @GetMapping(value = "/hasAuth2")
    public String hasAuth2(){
        return "/hasAuth2";
    }

    @GetMapping(value = "/hasAuth3")
    @Secured(value = {"auth3"})
    public String hasAuth3(){
        return "/hasAuth3";
    }

    @GetMapping(value = "/hasAuth4")
    @PreAuthorize(value = "hasAnyAuthority('auth3')")
    public String hasAuth4(){
        return "/hasAuth4";
    }

    @GetMapping(value = "/hasRole1")
    public String hasRole1(){
        return "/hasRole1";
    }

    @GetMapping(value = "/hasRole2")
    public String hasRole2(){
        return "/hasRole2";
    }

    @GetMapping(value = "/test1")
    public ResponseEntity test(){
        return ResponseEntity.ok("/okla");
    }
}
